<?php include $this->getViewFile('/common/Head'); ?>
<body class="J_scroll_fixed">
<style>
.product_img img {
    border:solid 3px #fff;
    margin-right:5px;
}
.product_img img.hover {
    border-color:#ff8800;
}
.product_img img.current {
    border-color:#df0001;
}
</style>
<div class="wrap J_check_wrap">
   <?php include $this->getViewFile('/common/Nav') ?>
   <form class="J_ajaxForm" action="<?php echo AdminBase::U("edit") ?>" method="post" id="myform">
   <div class="h_a">基本属性</div>
   <div class="table_full">
   <table width="100%" class="table_form contentWrap">
        <tbody>
          <tr>
            <th width="80">URL/ID</th>
            <td><input type="test" name="detail_url" class="input length_6" id="detail_url" value="<?php echo $data->detail_url ?>">
              <button class="btn J_ajax_getiteminfo" data-product_id="<?php echo $data->product_id ?>">获取最新信息</button> <input type="reset" class="button" value="重置"></td>
          </tr>
          <tr>
            <th>爱淘宝URL</th>
            <td><input type="test" name="click_url" class="input length_6" id="click_url" value="<?php echo $data->click_url ?>"></td>
          </tr>
          <tr>
            <th>商品ID</th>
            <td><em id="product_id"><?php echo $data->product_id ?></em><input type="hidden" name="product_id" value="<?php echo $data->product_id ?>"></td>
          </tr>
          <tr>
            <th >标签：</th>
            <td><?php include $this->getViewFile('/goods/tagInput') ?></td>
          </tr>
          <tr>
            <th>商品标题</th>
            <td><input type="text" name="goods_name" value="<?php echo $data->goods_name ?>" class="input length_6" id="goods_name"></td>
          </tr>
          <tr>
            <th>商品分类</th>
            <td><select name="cat_id">
                    <option value="0">请选择商品分类</option>
                    <?php echo CategoryModel::model()->htmlCategorySelectOption($data->cat_id) ?>
                    </select></td>
          </tr>
          <tr>
            <th>商品品牌</th>
            <td><?php echo Form::select(BrandModel::model()->getBrandArray(),$data->brand_id,'name="brand_id"','请选择品牌'); ?></td>
          </tr>
          <tr>
            <th>商品原价</th>
            <td><span style="color:#00F" id="p_price"><?php echo $data->p_price; ?></span><input type="hidden" name="p_price" class="p_price_val" value="<?php echo $data->p_price; ?>"></td>
          </tr>
          <tr>
            <th>活动价格</th>
            <td><input type="text" name="promo_price" class="input length_1" value="<?php echo  number_format($data->promo_price,2)?>" id="promo_price"> <input type="checkbox" name="is_vip" <?php echo $data->is_vip?'checked':'' ?> value="1"> <em>是设置的VIP价格</em> </td>
          </tr>
         <tr>
          <th>初始销量</td>
          <td><input type="text" name="start_sales" class="input length_1" value="<?php echo  $data->start_sales?>" id="start_sales"> <em>上活动前的销量</em></td>
         </tr>
         <tr>
          <th>销量</td>
          <td><input type="text" name="sales" class="input length_1" value="<?php echo  $data->sales?>" id="sales"> <em>目前的最新销量</em></td>
         </tr>
         <tr>
          <th>卖家包邮</td>
          <td><?php echo Form::radio(array(1=>'免运费',0=>'不免运费'),$data->freeshipping,'name="freeshipping"'); ?></td>
         </tr>
         <tr>
          <th>报名数量</td>
          <td><input type="text" name="stock" class="input length_1" value="<?php echo  (int)$data->stock?>"> <span class="gray">件</span></td>
         </tr>
         <tr>
          <th>是否展示</td>
          <td><?php echo Form::radio(array(1=>'上架',0=>'下架'),$data->status,'name="status"'); ?></td>
         </tr>
         <tr>
          <th>商品预告</td>
          <td><?php echo Form::radio(array(0=>'正常预告',1=>'不进行预告'),$data->isyugao,'name="isyugao"'); ?></td>
         </tr>
         <tr>
          <th>上架时间</td>
          <td><input type="text" name="start_time" class="input length_2 J_datetime " value="<?php echo  date('Y-m-d H:i',$data->start_time)?>" placeholder="上架时间"></td>
         </tr>
         <tr>
          <th>下架时间</td>
          <td><input type="text" name="end_time" class="input length_2 J_datetime " value="<?php echo  date('Y-m-d H:i',$data->end_time)?>" placeholder="下架时间"></td>
         </tr>
         <tr>
          <th>旺旺昵称</td>
          <td><a title="<?php echo $data->nick?>" target="_blank" href="http://amos.im.alisoft.com/msg.aw?v=2&amp;site=cntaobao&amp;s=2&amp;charset=utf-8&amp;uid=<?php echo urlencode($data->nick)?>"><?php echo $data->nick?><img src="http://amos.im.alisoft.com/online.aw?v=2&amp;site=cntaobao&amp;s=2&amp;charset=utf-8&amp;uid=<?php echo urlencode($data->nick)?>" alt=""></a></td>
         </tr>
         <tr>
          <th>所在地</td>
          <td>
            <span class="state"><?php echo $data->state?></span><input type="hidden" name="state" value="<?php echo $data->state ?>" />
            <span class="city"><?php echo $data->city?></span><input type="hidden" name="city" value="<?php echo $data->city ?>" />
          </td>
         </tr>
         <tr>
          <th>商品图片</td>
          <td><input type="text" name="product_img" value="<?php echo $data->product_img ?>" class="input" id="product_img" style="width:500px"></td>
         </tr>
         <tr>
          <th></td>
          <td>
          <div class="product_img">
          <img class="current" width="160" height="160" src="<?php echo $data->product_img ?>">
          </div></td>
         </tr>
         <tr>
          <th>推荐理由</td>
          <td><textarea type="text" name="goods_brief" cols="60" rows="6"><?php echo $data->goods_brief?></textarea></td>
         </tr>
         <tr>
          <th>扩展属性</td>
          <td>
          <input type="hidden" value="0" name="is_best">
          <input type="hidden" value="0" name="is_new">
          <input type="hidden" value="0" name="is_hot">
          <input type="hidden" value="0" name="is_format">
          <input type="hidden" value="0" name="is_stock">
          <input type="checkbox" name="is_best" <?php echo $data->is_best?'checked':'' ?> value="1"> 推荐 <input type="checkbox" name="is_new" <?php echo $data->is_new?'checked':'' ?> value="1"> 新品 <input type="checkbox" name="is_hot" <?php echo $data->is_hot?'checked':'' ?> value="1"> 热卖 <input type="checkbox" name="is_format" <?php echo $data->is_format?'checked':'' ?> value="1"> 多规格 <input type="checkbox" name="is_stock" <?php echo $data->is_stock?'checked':'' ?> value="1"> 已售完</td>
         </tr>
         <tr>
          <th>Level</td>
          <td><?php echo Form::select(CustomBlockModel::model()->getLevelArray(),$data->level,'name="level"'); ?></td>
         </tr>
          <tr>
            <th>所属专场</th>
            <td><?php echo Form::select(GoodsBmModel::getSpecialHtmlList(),$data->special_id,'name="special_id"', '默认'); ?></td>
          </tr>
         <tr>
          <th>商品排序</td>
          <td><input type="text" name="listorder" class="input length_1" value="<?php echo  (int)$data->listorder?>"></td>
         </tr>
        </tbody>
      </table>
   </div>
   <div class="btn_wrap">
      <div class="btn_wrap_pd">             
        <input type="hidden" name="goods_id" value="<?php echo $data->goods_id ?>">
		<input type="hidden" name="nick" value="<?php echo $data->nick ?>" />
		<input type="hidden" name="item_type" value="<?php echo $data->item_type ?>" />
        <button class="btn btn_submit mr10 J_ajax_submit_btn" type="submit">确认修改</button>
      </div>
    </div>
    </form>
</div>
<script src="<?php echo $staticUrl; ?>statics/js/common.js"></script>
<script>
function product_img(){
	$('div.product_img img').click(function() {
		$('div.product_img img').removeClass('current');
		$(this).addClass('current');
		$('#product_img').val(this.src);
    });
}
$(function(){
	//点击图片
	if($('div.product_img img').length){
		product_img();
	}
	if($('button.J_ajax_getiteminfo').length){
		$('button.J_ajax_getiteminfo').click(function(){
			var but = this;
			var text = $(but).text();
			//var product_id = $(this).data('product_id');
			var product_id = $('input[name="detail_url"]').val();
			$(but).text('获取中...');
			$.getJSON('<?php echo AdminBase::U("goodsbm/public_iteminfo") ?>',{product_id:product_id},function(data){
				$(but).text(text);
				if(data.status){
					//商品地址
					$('#detail_url').val(data.detail_url);
					$('#goods_name').val(data.title);
					//原价
					$('#p_price').html(data.p_price);
					$('input[name="p_price"]').val(data.p_price);
					//店铺类型
					$('input[name="item_type"]').val(data.item_type);
					//活动价
					//$('input[name="promo_price"]').val(data.promo_price);
					//商品ID
					$('#product_id').html(data.product_id);
					$('input[name="product_id"]').val(data.product_id);
					//销量
					if(data.item_type==0){
						$('#sales').val(data.sales);
					}
					//商品地址
					$('.detail_url').val(data.detail_url);
					//地区
					$('.state').html(data.province);
					$('input[name="state"]').val(data.province);
					$('.city').html(data.city);
					$('input[name="city"]').val(data.city);
					//旺旺
					$('input[name="nick"]').val(data.nick);
					
					//图片
					var imgstr = '';
					if (data.images) {
						$.each(data.images,function(i,v){
							if(i == 0){
								$('#product_img').val(v);
								imgstr += '<img class="current" width="160" height="160" src=' + v + ' />';
							}else{
								 imgstr += '<img  width="160" height="160"  src=' + v + ' />';
							}
						});
						$('div.product_img').html(imgstr);
						product_img();
					}
				}
			});
			return false;
		});
	}
});
</script>
</body>
</html>